<?php

namespace backend\module\content\models;

use Yii;

/**
 * This is the model class for table "{{%page}}".
 *
 * @property int $id
 * @property string $title
 * @property int $catid
 * @property string $description
 * @property string $keywords
 * @property int $userid
 * @property string $url
 * @property int $created
 * @property string $content
 */
class Page extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%page}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'catid', 'userid'], 'required'],
            [['catid', 'userid'], 'integer'],
            [['description', 'content'], 'string'],
            [['title', 'keywords', 'url'], 'string', 'max' => 255],
            [['created'],'default','value'=>function(){
                return time();
            }]
        ];
    }
    public function save($runValidation = true, $attributeNames = null) {
        $this->created = strtotime($this->created);
        parent::save($runValidation, $attributeNames);
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'ID'),
            'title' => Yii::t('common', 'Title'),
            'catid' => Yii::t('common', 'Catid'),
            'description' => Yii::t('common', 'Description'),
            'keywords' => Yii::t('common', 'Keywords'),
            'userid' => Yii::t('common', 'Userid'),
            'url' => Yii::t('common', 'Url'),
            'created' => Yii::t('common', 'Created'),
            'content' => Yii::t('common', 'Content'),
        ];
    }
}
